Repository navigation
Trim dead exports and consolidate duplicated helpers - #85
Merged
Merged
Conversation
Salvages the high-signal portion of the parked `cleanup/tier1-dead-exports` branch (commit `e2285b3`, May 12), re-derived on top of post-rename `main`. No "cc-shell" strings introduced. Two threads of cleanup land together. ## Dead exports / dead returns - src/main/window/mainWindow.ts — delete `getMainWindow()` (zero importers internal or external). - src/main/sessionManager.ts — privatize `ManagerEvents`, `SpawnOptions`, `SpawnResult`. These three types are consumed only by the EventEmitter overloads on the SessionManager interface in the same file. WHY-comments capture why they should stay private. - src/renderer/.../claudeImages.ts — privatize 5 internal-only symbols: `MAX_CLAUDE_IMAGE_BYTES`, `SUPPORTED_CLAUDE_IMAGE_MEDIA_TYPES`, `fileToDataUrl`, `parseDataUrl`, `estimateBase64DecodedBytes`. The only consumer (useClaudeImagePaste) only pulls the predicates and ingress functions. WHY-comment documents the public surface. - src/providers/claude/runtime/claudeSession.ts — remove the `terminalToMarkdown` re-export. It was a compat shim from when the function lived inline; today its sole definition is in src/shared/runtime/ptyScreen.ts and nothing imports it via claudeSession. HISTORICAL note left in place. - src/renderer/.../useClaudeImagePaste.ts — drop `appendDraftImages` from the hook's return object. The only caller (TileLeaf) only destructures `handlePaste` and `removeDraftImage`; the append helper is purely internal now (paste-only ingress). - src/providers/codex/types/codexTranscript.ts — delete unused `CodexSessionMeta`, `CodexResponseItem`, `CodexEventMsg` types and the `isCodexConversationEntry` guard. Zero external imports; consumers handle `payload: unknown` with inline narrowing. ## New shared helpers + dedup call sites Five new modules replace hand-duplicated copies: - src/renderer/src/lib/relativeTime.ts — replaces 4 copies in PathPickerModal, PromptSearchModal, AgentActivityModal, and WorktreesBar. Picked the most complete variant (years + 'just now' branch). UX delta for callers that lacked 'just now': fresh timestamps now show 'just now' instead of '2s ago' — softer, no regression risk. - src/renderer/.../features/workspace/lib/sessionDisplay.ts — consolidates `cwdBasename` + `providerGlyph` from AgentActivityModal and PromptSearchModal. Wider provider signature (claude|codex|terminal) so the agent-activity surface doesn't have to special-case. - src/renderer/.../features/system-perf/formatBytes.ts — consolidates the two badge/popover copies of the SI byte formatter. Tunable `fractionDigits = 2` default. - src/renderer/.../workspace/codex/eventCursor.ts — `codexTurnIdFromEventPayload` + `codexEventType`, replacing three copies across history.ts / initialHistory.ts / useIpcSubscriptions.ts. WHY-comment captures why the payload-level turn_id is load-bearing fallback evidence (pagination + IPC bursts can start after the defining `turn_context`). - src/shared/lib/asRecord.ts — shared unknown-JSON narrowing helper. Replaces two copies in workspace/codex/rollout.ts and providers/codex/renderer/rows/CodexRows.tsx. NOTE: CodexRows' local copy did NOT exclude arrays — replacing with the stricter shared helper means arrays now return null. Every call site uses `.raw` / `.input` property reads that would be undefined on arrays anyway, so this is a free safety improvement, documented in a WHY-comment at the import. ## Verification - npm run test:review-fixes — settings/prompt-templates/session-ownership all green - npm run test:work-context — green - npm run build:app — green - git diff main | grep -ic "cc-shell" — 0 17 modified + 5 new files, +88/-263. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2 of 3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Salvages the high-signal portion of the parked
cleanup/tier1-dead-exportsbranch (commite2285b3, May 12), re-derived on top of post-renamemain. No "cc-shell" strings introduced.Two threads of cleanup land together.
Dead exports / dead returns
src/main/window/mainWindow.tsgetMainWindow()— zero importers (internal or external).src/main/sessionManager.tsManagerEvents,SpawnOptions,SpawnResult. Consumed only by the EventEmitter overloads in the same file.src/renderer/.../claudeImages.tssrc/providers/claude/runtime/claudeSession.tsterminalToMarkdownre-export — compat shim with zero callers; real definition is insrc/shared/runtime/ptyScreen.ts.src/renderer/.../useClaudeImagePaste.tsappendDraftImagesfrom hook return. Only caller (TileLeaf) destructureshandlePaste+removeDraftImageonly.src/providers/codex/types/codexTranscript.tsCodexSessionMeta,CodexResponseItem,CodexEventMsg,isCodexConversationEntry. Zero external imports.New shared helpers + dedup call sites
Five new modules replace hand-duplicated copies on main:
src/renderer/src/lib/relativeTime.tsPathPickerModal,PromptSearchModal,AgentActivityModal,WorktreesBar).src/renderer/.../features/workspace/lib/sessionDisplay.ts(cwdBasename+providerGlyph)src/renderer/.../features/system-perf/formatBytes.tsSystemPerfBadge,SystemPerfPopover).src/renderer/.../workspace/codex/eventCursor.ts(codexTurnIdFromEventPayload+codexEventType)history.ts,initialHistory.ts,useIpcSubscriptions.ts).src/shared/lib/asRecord.tsworkspace/codex/rollout.ts,providers/codex/renderer/rows/CodexRows.tsx).One semantic delta worth flagging
CodexRows.tsx's localasRecorddid NOT exclude arrays. The shared helper does. Every call site there uses.raw/.inputproperty reads that would be undefined on arrays anyway, so the stricter check is a free safety improvement, documented in a WHY-comment at the import.A handful of UI surfaces will also pick up a 'just now' label for sub-5s timestamps (they previously rendered
1s ago/2s ago). Softer UX, no regression risk.Why salvaged, not rebased
Same reason as PR #84 — the parked branch was authored before the cc-shell → agent-code rename and would reintroduce "cc-shell" strings across README, package.json, CLAUDE.md, AGENTS.md, etc. The intent was extracted and re-applied carefully on current
main.Test plan
npm run test:review-fixes(settings, prompt-templates, session-ownership) — passnpm run test:work-context— passnpm run build:app— passgit diff main | grep -ic 'cc-shell'— 0Stats
17 modified + 5 new files, +88/-263.
🤖 Generated with Claude Code